﻿<link href="~/Content/js/map/main1119.css" rel="stylesheet" />
@*<script src="~/Content/js/jquery/jquery.min.js"></script>*@
<script src="~/Content/js/jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=0becd8fe1015922768e948820a0d388a&plugin=AMap.Autocomplete"></script>
<script type="text/javascript" src="~/Content/js/map/addToolbar.js"></script>
<div id="container"></div>
<div id="myPageTop">
    <table>
        <tr>
            <td>
                <label>按关键字搜索：</label>
            </td>
            <td class="column2">
                <label>左击获取经纬度：</label>
            </td>
        </tr>
        <tr>
            <td>
                <input type="text" placeholder="请输入关键字进行搜索" id="tipinput">
            </td>
            <td class="column2">
                <input type="text" readonly="true" id="lnglat">
            </td>
        </tr>
    </table>
</div>
<script type="text/javascript">

    var index = parent.layer.getFrameIndex(window.name);
    var point = new Array();
    function Point() {
        return point;
    }

    var map = new AMap.Map("container", {
        resizeEnable: true
    });
    //为地图注册click事件获取鼠标点击出的经纬度坐标
    var clickEventListener = map.on('click', function (e) {
        document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat()
        point.push(e.lnglat.getLng());
        point.push(e.lnglat.getLat());
    });
    var auto = new AMap.Autocomplete({
        input: "tipinput"
    });
    AMap.event.addListener(auto, "select", select);//注册监听，当选中某条记录时会触发
    function select(e) {
        if (e.poi && e.poi.location) {
            map.setZoom(15);
            map.setCenter(e.poi.location);
        }
    }
</script>
